#include "task.h"

/*==============================================<任务基类>==============================================*/



/*==============================================<任务派生类>==============================================*/
/*========================<任务派生类 1 --示例>========================*/
PrintNumberTask::PrintNumberTask(int num) :number(num) {}

void PrintNumberTask::execute()
{
    std::this_thread::sleep_for(std::chrono::milliseconds(100)); // 模拟任务耗时
    std::cout <<
        "Executing PrintNumberTask: " << number << " by thread " << std::this_thread::get_id()
        << std::endl;
}

/*========================<任务派生类 2 --示例>========================*/
CalculateTask::CalculateTask(int x, int y) :a(x), b(y) {}

void CalculateTask::execute()
{
    std::this_thread::sleep_for(std::chrono::milliseconds(50)); // 模拟任务耗时
    int result = a + b;
    std::cout <<
        "Executing CalculateTask: " << a << " + " << b << " = " << result << " by thread " << std::this_thread::get_id()
        << std::endl;
}